package demo;

import java.net.UnknownHostException;
import java.io.IOException;
import java.net.InetAddress;

public class demo4 {
    public static void main(String[] args) throws IOException {
        InetAddress address = InetAddress.getByName("www.baidu.com");
        System.out.println(address.getHostName());
        System.out.println(address.getHostAddress());
        //判断在8秒内是否与百度建立联系
        boolean b = address.isReachable(8000);
        System.out.println(b);
    }
}
